package cn.aj.exm.fallback;

import cn.aj.exm.domain.UserMovie;
import cn.aj.exm.exception.GlobalExceptionEnum;
import cn.aj.exm.feign.UserMovieService;
import cn.aj.exm.result.JsonResult;
import feign.hystrix.FallbackFactory;
import org.springframework.stereotype.Component;

@Component
public class UserMovieServiceFallbackFactory implements FallbackFactory<UserMovieService> {
    @Override
    public UserMovieService create(Throwable throwable) {
        return new UserMovieService() {
            @Override
            public JsonResult userMovieLoadTicket(Long movieId, Long userId) {
                return JsonResult.error(GlobalExceptionEnum.ERROR.getMessage(), GlobalExceptionEnum.ERROR.getCode());
            }

            @Override
            public JsonResult saveOrUpdate(UserMovie userMovie) {
                return JsonResult.error(GlobalExceptionEnum.ERROR.getMessage(), GlobalExceptionEnum.ERROR.getCode());
            }
        };
    }
}
